package org.road0329.tools.proto_parse_tool.enums;

/**
 * 表计类型
 * 
 * @author zdd
 */
public enum MeterTypeEnum  {
                           METER_POWER("00", "电表"), //
                           METER_POWER_32("32", "三相表(32)"), //
                           METER_POWER_51("51", "单相表(51)"), //
                           METER_WATER_COLD("10", "冷水表(10)"), //
                           METER_WATER_COLD_17("17", "冷水表(17)"), //
                           METER_WATER("11", "中水表"), //
                           METER_WATER_PURE("12", "纯净水表"), //
                           METER_WATER_HOT("13", "热水表"), //
                           METER_WATER_ELEC("19", "电子水表"), //
                           METER_HEAT_HOT("20", "热量表（计热量）"), //
                           METER_HEAT_COLD("21", "热量表（计冷量）"), //
                           METER_FLOW("23", "流量计"), //
                           METER_GAS("30", "燃气表"), //
                           METER_OTHER("40", "其他仪表");

    private final String value;
    private final String text;

    MeterTypeEnum(String value, String text) {
        this.value = value;
        this.text = text;
    }

    public String getValue() {
        return value;
    }

    public String getText() {
        return text;
    }

    /**
     * 通过传入的字符串匹配枚举，传入值
     * 
     * @param value
     * @return
     */
    public static MeterTypeEnum getEnmuByValue(String value) {
        for (MeterTypeEnum at : MeterTypeEnum.values()) {
            if (at.getValue().equals(value)) {
                return at;
            }
        }
        return null;
    }

    /**
     * 通过传入的字符串匹配枚举获得描述，传入值
     * 
     * @param value
     * @return
     */
    public static String getText(String value) {
        MeterTypeEnum type = getEnmuByValue(value);
        return type == null ? "" : type.text;
    }

}
